<template>
  <view class="app-container">
    <router-view />
  </view>
</template>

<script>
export default {
  name: 'App',
  onLaunch: function() {
    console.log('App Launch')
    // 初始化主题
    this.initTheme()
  },
  onShow: function() {
    console.log('App Show')
  },
  onHide: function() {
    console.log('App Hide')
  },
  methods: {
    initTheme() {
      // 从本地存储获取主题设置
      const theme = uni.getStorageSync('theme') || 'light'
      this.$store.commit('setTheme', theme)
      this.applyTheme(theme)
    },
    applyTheme(theme) {
      // 应用主题
      if (theme === 'dark') {
        document.documentElement.classList.add('dark-theme')
      } else {
        document.documentElement.classList.remove('dark-theme')
      }
    }
  }
}
</script>

<style lang="scss">
/* 全局样式 */
page {
  background-color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

.app-container {
  width: 100%;
  height: 100%;
}

/* 主题样式 */
.dark-theme {
  page {
    background-color: #1a1a1a;
    color: #ffffff;
  }
}

/* 通用样式 */
.container {
  padding: 20rpx;
}

.card {
  background: #fff;
  border-radius: 10rpx;
  padding: 30rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}

.btn {
  display: inline-block;
  padding: 20rpx 40rpx;
  background: #007aff;
  color: #fff;
  border-radius: 10rpx;
  text-align: center;
  font-size: 28rpx;
  cursor: pointer;
  
  &:active {
    opacity: 0.8;
  }
}

.btn-primary {
  background: #007aff;
}

.btn-success {
  background: #4cd964;
}

.btn-warning {
  background: #f0ad4e;
}

.btn-danger {
  background: #dd524d;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-20 {
  margin-top: 20rpx;
}

.mb-20 {
  margin-bottom: 20rpx;
}

.p-20 {
  padding: 20rpx;
}

.flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-between {
  justify-content: space-between;
}

.flex-around {
  justify-content: space-around;
}

.flex-1 {
  flex: 1;
}
</style>
